package com.sunop.judge.properties;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.core.DefaultDockerClientConfig;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.core.DockerClientImpl;
import com.github.dockerjava.netty.NettyDockerCmdExecFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DockerConfig {

    @Bean
    public DockerClient dockerClient() {
        // 创建默认的 Docker 客户端配置
        DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
                .withDockerHost("tcp://192.168.150.103:2375") // 远程 Docker 主机
                .withDockerTlsVerify(false) // 是否启用 TLS 验证
                .build();
        // 使用 Netty 作为 HTTP 客户端
        return DockerClientImpl.getInstance(config)
                .withDockerCmdExecFactory(new NettyDockerCmdExecFactory());
    }
}